from django.db import models

# Create your models here.
class Cate(models.Model):
  name = models.CharField(max_length=20, verbose_name='分类名称')
  def __str__(self):
    return self.name
  class Meta:
    db_table = 'newscate'
class News(models.Model):
  title = models.CharField(max_length=100, verbose_name='标题')
  content = models.TextField(verbose_name='内容')
  read= models.IntegerField(verbose_name='阅读量', default=0)
  cate = models.ForeignKey(Cate, on_delete=models.CASCADE, verbose_name='分类')
  img=models.CharField(max_length=100, verbose_name='图片', null=True, blank=True)
  addtime = models.DateTimeField(auto_now_add=True, verbose_name='添加时间')
  def __str__(self):
    return self.title
  class Meta:
    db_table = 'news'